package round89;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;

public class C {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String split[] = in.readLine().split(" ");
        int N = Integer.parseInt(split[0]), K = Integer.parseInt(split[1]);
        String str = in.readLine();
        byte[] car = new byte[str.length()];
        for (int i = 0; i < car.length; i++) {
            car[i] = (byte) (str.charAt(i) - '0');
        }
        int min = Integer.MAX_VALUE, val = 0;
        List<DiffO> diff = new ArrayList<DiffO>();
        List<DiffO> temp = null;
        PriorityQueue<DiffO> pq = new PriorityQueue<DiffO>(K);
        
        for (int i = 0; i <= 9; i++) {
            pq.clear();
            diff.clear();
            for (int j = 0; j < car.length; j++) {
                DiffO diffO = new DiffO();
                diffO.diff = (byte) Math.abs(i - car[j]);
                diffO.pos = j;
                diffO.comp = (byte) (i - car[j]);
                pq.add(diffO);
            }

            int cost = 0;
            for (int j = 0; j < K; j++) {
                DiffO t = pq.poll();
                cost += t.diff;
                diff.add(t);
            }

            if (cost < min) {
                min = cost;
                temp = diff;
                diff = new ArrayList<DiffO>();
                val = i;
            } else if (cost == min) {
                if (compare(diff, temp, car, i, val) < 0) {
                    temp = diff;
                    diff = new ArrayList<DiffO>();
                    val = i;
                }
            }
        }

        System.out.println(min);
        for (int i = 0; i < temp.size(); i++) {
            DiffO t = temp.get(i);
            car[t.pos] = (byte) val;
        }
        for (int i = 0; i < car.length; i++) {
            System.out.print(car[i]);
        }
        System.out.println();
    }

    private static int compare(List<DiffO> diff, List<DiffO> temp, byte[] car, int v1, int v2) {
        byte d[] = new byte[car.length], t[] = new byte[car.length];
        for (int i = 0; i < d.length; i++) {
            d[i] = t[i] = car[i];
        }

        for (int i = 0; i < temp.size(); i++) {
            DiffO tmp = diff.get(i);
            d[tmp.pos] = (byte) v1;
            tmp = temp.get(i);
            t[tmp.pos] = (byte) v2;
        }
        for (int i = 0; i < d.length; i++) {
            if(d[i]!= t[i])
                return d[i] - t[i];
        }
        return 0;
    }

    private static class DiffO implements Comparable<DiffO> {

        byte diff = 0;
        int pos = 0;
        byte comp;


        public int compareTo(DiffO o) {
            if (diff != o.diff)
                return diff - o.diff;
            if (comp != o.comp) {
                if (comp < o.comp)
                    return -1;
                else return 1;
            }
            if (comp < 0)
                return pos - o.pos;
            else if (comp > 0)
                return -(pos - o.pos);
            return 0;
        }
    }
}
